package com.xuelang.pipeline.worker.client.common.feign;

import com.xuelang.pipeline.worker.client.common.result.ApiResult;
import com.xuelang.pipeline.worker.client.crd.IPipelineService;
import com.xuelang.pipeline.worker.client.crd.dto.PipelineDTO;
import com.xuelang.pipeline.worker.client.crd.dto.PipelineRunDTO;
import com.xuelang.pipeline.worker.client.crd.tekton.v1beta.pipeline.V1Beta1Pipeline;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;

/**
 * @author liuyuan.ly
 * @since 2024/6/25 19:09
 */
@Slf4j
@Component
public class TektonServiceFallbackImpl implements IPipelineService {
    private final String fallReason = "服务降级：远程服务不可用";
    private final ApiResult<Boolean> apiResultBoolean = ApiResult.<Boolean>failT("worker返回异常：" + fallReason);
    private final ApiResult<List<V1Beta1Pipeline>> apiResultPipelineList = ApiResult.<List<V1Beta1Pipeline>>failT("worker返回异常：" + fallReason);
    private final ApiResult<String> apiResultString = ApiResult.<String>failT("worker返回异常：" + fallReason);

    @Override
    public ApiResult<Boolean> createPipeline(PipelineDTO dto) { return apiResultBoolean; }
    @Override
    public ApiResult<List<V1Beta1Pipeline>> getPipelineList(PipelineDTO dto) { return apiResultPipelineList; }
    @Override
    public ApiResult<Boolean> createPipelineRun(PipelineRunDTO dto) { return apiResultBoolean; }
    @Override
    public ApiResult<String> getPipelineRunList(PipelineRunDTO dto) { return apiResultString; }
    @Override
    public ApiResult<Boolean> cancelPipelineRun(PipelineRunDTO pipelineRunDTO) { return apiResultBoolean; }
}
